"""
This script simply copies the contents of base_init to the test_root/results/html.
It the *dst* directory already exists, only the _templates, _static, reogo and help directories are copied over.
These directories may contain updates files (such as css and js files).

"""

import shutil, os
from {{ module.lower() }} import {{ module }}

html_dir = {{ module }}.get_data_directory() + '/results/html'

if not os.path.exists(html_dir):
	print "Creating HTML source tree: " + os.path.normpath(html_dir)+"...",
	shutil.copytree({{ module }}.get_project_root()+'/src/html/base_init/', html_dir)
else:
	print " HTML source tree already exists...",

	#removes template dirs and files
	if os.path.exists(os.path.normpath(html_dir+'/source/reogo')):
		shutil.rmtree(os.path.normpath(html_dir+'/source/reogo'))
	if os.path.exists(os.path.normpath(html_dir+'/source/_static')):
		shutil.rmtree(os.path.normpath(html_dir+'/source/_static'))
	if os.path.exists(os.path.normpath(html_dir+'/source/_templates')):
		shutil.rmtree(os.path.normpath(html_dir+'/source/_templates'))
	if os.path.exists(os.path.normpath(html_dir+'/source/conf.py')):
		os.remove(os.path.normpath(html_dir+'/source/conf.py'))
	if os.path.exists(os.path.normpath(html_dir+'/source/help')):
		shutil.rmtree(os.path.normpath(html_dir+'/source/help'))

	# updates template dirs and files
	shutil.copytree({{ module }}.get_project_root()+'/src/html/base_init/source/reogo', os.path.normpath(html_dir+'/source/reogo'))
	shutil.copytree({{ module }}.get_project_root()+'/src/html/base_init/source/_static', os.path.normpath(html_dir+'/source/_static'))
	shutil.copytree({{ module }}.get_project_root()+'/src/html/base_init/source/_templates', os.path.normpath(html_dir+'/source/_templates'))
	shutil.copyfile({{ module }}.get_project_root()+'/src/html/base_init/source/conf.py', os.path.normpath(html_dir+'/source/conf.py'))
	shutil.copytree({{ module }}.get_project_root()+'/src/html/base_init/source/help', os.path.normpath(html_dir+'/source/help'))

print " done."

